package ru.spbu.math.android.cbrf.view;

import ru.spbu.math.android.cbrf.model.RateType;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.util.Log;

/**
 * This class is OnClickListener for dialog with list of RateTypes.
 * 
 * @author Olga.Nikonova
 */
public class OnRateTypeClickListener implements OnClickListener {

	private static final String TAG = "RateTypeListner";

	private RateTypeListAdapter rtListAdapter;

	public OnRateTypeClickListener(RateTypeListAdapter listAdapter) {
		super();
		this.rtListAdapter = listAdapter;
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		RateType rateType = (RateType) rtListAdapter.getItem(which);
		Log.d(TAG, "Selected RateType: " + rateType.toString());

		// change selectedRateType
		rtListAdapter.setSelectedRateType(rateType);
	}

}
